<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>艺术家列表</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script language="javascript" type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
.table_tr{cursor: pointer;background: #ffffff;}
.table_tr td{padding: 5px 10px;text-align: center;}
</style>
<script type="text/javascript">

	/**************  查询  *******************/
	function search(){
		
		var actionUrl = "${ctx}/painter/listPainterStar.do";

		$("#curPage").val(1);
		$("#searchForm").attr("action",actionUrl);
		$("#searchForm").submit();
	}
	

	/******改变艺术家状态*****/
	function changeState(id,status){
		if(status == '2'){
			if (window.confirm("该操作将删除艺术家及其所有作品，确定执行此操作？")) {
				$.ajax( {
					type : "POST",
					url : "${ctx}/painter/changeUploadState.do?painter.id="+id+"&operateStr="+status,
					timeout : 6000,
					async : false, //ajax同步
					success : function(data, textStatus) {
						if(data == '0000'){
							window.location.reload(true);
						}
					}
				});
			}
		}else{
			$.ajax( {
				type : "POST",
				url : "${ctx}/painter/changeUploadState.do?painter.id="+id+"&operateStr="+status,
				timeout : 6000,
				async : false, //ajax同步
				success : function(data, textStatus) {
					if(data == '0000'){
						window.location.reload(true);
					}
				}
			});
		}
	}
	

	/******  预览   ****/
	function preview(id){
		var curPage = $("#curPage").val();
		var	actionUrl =  "${ctx}/painter/showDetail.do?id="+id+"&curPage="+curPage;

		window.location.href = actionUrl ;
	}
	
	$(function(){
		  
		m2('m1_005','m1_005_05');
		
   		$(".table_tr").hover(function(){
   			$(this).css({background:"yellow"});
			},function(){
				$(this).css({background:"#ffffff"});
			}
		);	
		    
	});
	
	/**更改排序*/
	function changeSequence(){
		var sequenceArray = [];
		
		$(".table_tr").each(function(i,n){
		     var id = $(this).children().eq(0).find("input[name='id']").val();
			 sequenceArray[i] = "{"+id + ","+ i+"}";
	    });
		
		
		$.ajax( {
			type : "POST",
			url : "${ctx}/painter/changeSequence.do",
			data: "data="+sequenceArray+"&t="+new Date(),
			timeout : 6000,
			async : false, //ajax同步
			success : function(data) {
				if(data == '0000'){
					alert("排序成功");
					window.location.href = "${ctx}/painter/listPainterStar.do?curPage=${page.pageNo }&pageSize=${page.pageSize }";
					return;
				}else{
					alert("排序失败");
				}
			}
		});
	}
	
	/**放弃排序**/
	function cancelSequence(){
		location.href = "${ctx}/painter/listPainterStar.do?curPage=${page.pageNo }&pageSize=${page.pageSize }";
	}
	

</script>
</head>

<body>

<!-- 页面头部  -->
<jsp:include page="/commons/head_member.jsp"></jsp:include>

<form action="${ctx}/painter/listPainterStar.do" id="searchForm" name="searchForm" method="post">
<table width="960" cellpadding="0" cellspacing="0" class="tbl_list_border" align="center">
<tr><td>
		<table width="900" border="0" cellspacing="0" cellpadding="0" align="center" style="margin: 0 auto;">
			<tr><td>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td class="nw12a" width="60" align="right">
				艺术家：</td><td><input name="filterTxt" value="name" type="hidden"/>
				<input name="filterValue" type="text" size="15" value="${filterValue }"/>
				<img src="../images/an25.gif" width="50" height="21" onclick="search()" style="cursor: pointer;vertical-align: middle;" >
				</td>
			</tr>
			<tr>
			<td class="nw12a"  align="right">
				开始时间：</td><td style="font-family: 宋体;font-size: 12px;"> <input name="startDate" type="text" size="15" onClick="WdatePicker()" value="<fmt:formatDate value='${startDate }' pattern='yyyy-MM-dd'/>">&nbsp;&nbsp;
              	结束时间：<input name="endDate" type="text" size="15" onClick="WdatePicker()"  value="<fmt:formatDate value='${endDate }' pattern='yyyy-MM-dd'/>">&nbsp;&nbsp;
				<img src="../images/an25.gif" width="50" height="21" onclick="search()" style="cursor: pointer;vertical-align: middle;" >
				</td>
			</tr>
			<tr><td height="5"></td></tr>
			</table>
			</td></tr>
			<tr><td colspan="100%">
             <table width="900" border="0" cellpadding="0" cellspacing="1" bordercolor="#0099CC" bgcolor="#0099CC" id="data_table">
                  <tr bgcolor="#CDE1ED">
                    <td class="nw12b" height="30" align="center">序号</td>
                    <td class="nw12b" align="center">艺术家名字</td>
                    <td class="nw12b" align="center">发布者</td>
                    <td class="nw12b" align="center">发布时间</td>
                    <td class="nw12b" align="center">作品数量</td>
                    <td class="nw12b" align="center">编辑</td>
                    </tr>
	                   	<c:forEach items="${page.result}" var="result" varStatus="status">
		                   <tr class="table_tr">
		                    <td  height="30">
			                    ${status.count }
			                    <input type="hidden" name="id" id="id_${status.index }" value="${result.id }"/>
			                    <input type="hidden" name="sortflag" id="sortflag_${status.index }" value="${result.sortFlag }"/>
		                    </td>
		                    <td>
		                   	 	<a href="${ctx }/front/painterAction!painterDetail.do?id=${result.id }" target="_blank">
		                    		${result.name }
		                    	</a>
		                    </td>
		                    <td>${result.entryPerson.username }</td>
		                    <td><fmt:formatDate value="${result.uploadTime }" pattern="yyyy-MM-dd HH:mm"/></td>
		                    <td>${result.totalCount }</td>
		                    <td>
			                    <a name="modifyHref" style="color: blue;cursor: pointer" href="${ctx}/painter/showDetail.do?painter.id=${result.id }">修改</a>
			                       &nbsp;
			                    <a href="javascript:changeState(${result.id },'2')" style="color: blue;cursor: pointer" >删除</a>
			                    	&nbsp;	               			                    
			                    <c:choose>
			                    	<c:when test="${result.auditState.id == 3 }">
			                    		<a style="color: blue;cursor: pointer"  href="javascript:changeState(${result.id },'4')">不通过</a>&nbsp;
			                    	</c:when>
			                    	<c:otherwise>
			                    		<a style="color: blue;cursor: pointer"  href="javascript:changeState(${result.id },'3')">通过</a>&nbsp;
			                    	</c:otherwise>
			                    </c:choose>
			                   	 <c:if test="${result.uploadState.id == 1 }">
										<a style="color: blue;cursor: pointer"  href="javascript:changeState(${result.id },'1')">隐藏</a>&nbsp;
								</c:if>
								<c:if test="${result.uploadState.id == 2 }">
									<a style="color: blue;cursor: pointer"  href="javascript:changeState(${result.id },'5')">显示</a>&nbsp;
								</c:if>
								<c:choose>
									<c:when test="${result.sortFlag == 0 }">
										<a style="color: blue;"  href="javascript:changeState(${result.id },'6')">置顶</a>
									</c:when>
									<c:otherwise>
										<a style="color: blue;"  href="javascript:changeState(${result.id },'7')">取消置顶</a>
									</c:otherwise>
								</c:choose>
								    <input type="button" value="↑" onclick="moveUp()" style="cursor:pointer;"/>
									<input type="button" value="↓" onclick="moveDown()" style="cursor:pointer;"/>
		                    </td>
		                   </tr>
	                 	 </c:forEach>
              </table></td>
            </tr>
            <tr>
              <td class="nw12a">
                    <input type="button" name="btn_changeSequence" id="btn_changeSequence" onclick="changeSequence()" style="cursor: pointer;" value="确认排序"/>
              		<input type="button" name="cancel_changeSequence" id="cancel_changeSequence" onclick="cancelSequence()" style="cursor: pointer;" value="放弃排序"/>
             </td>
              <td colspan="5" class="nw12a" align="right" height="30"><jsp:include page="/commons/paging_footer.jsp"/> </td>
            </tr>
          </table>
 </td></tr>
 </table>
 </form>
    
<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>